// 登录
<template>
  <div class="login">
    <!-- 图片 -->
    <div class="top">
      <img src="http://xl.9yuecloud.com/assets/img/login.a4c656a9.png" alt="" />
    </div>
    <!-- 表单 -->
    <div class="form">
      <div class="left">
        <div class="left_top">用户名</div>
        <div class="left_bom">密码</div>
      </div>
      <div class="right">
        <div class="right_top">
          <input type="text" placeholder="用户名" v-model="form.mobile" />
        </div>
        <div class="right_bom">
          <input type="text" placeholder="密码" v-model="form.password" />
        </div>
      </div>
    </div>
    <div class="bom">
      <div class="left">找回密码</div>
      <div class="right" @click="$router.push('/smslogin')">
        注册/验证码登录
      </div>
    </div>

    <div class="button">
      <button @click="login">登录</button>
    </div>
  </div>
</template>

<script>
import { getLogin } from "@/request/longin";
import { Toast } from "vant";
let reg = /^(?:(?:\+|00)86)?1[3-9]\d{9}$/;
export default {
  name: "",
  components: {},
  data() {
    return {
      form: {
        mobile: "",
        password: "",
        type: "",
        client: 1,
      },
    };
  },
  created() {},
  mounted() {},
  methods: {
    // 登录
    async login() {
      let obj = {
        mobile: this.form.mobile,
        password: this.form.password,
        type: 1,
        client: 1,
      };
      if (reg.test(this.form.mobile)) {
        let res = await getLogin(obj);
        console.log(res);
        if (res.data.code == 200) {
          localStorage.setItem("msmktoken", res.data.data.remember_token);
          this.$router.push("/user");
        } else {
          this.$Toast(res.data.msg);
        }
      } else {
        Toast("手机号格式错误");
      }
    },
  },
};
</script>
<style scoped lang='scss'>
.login {
  width: 100%;
  height: 100%;
  .top {
    width: 100%;
    height: 200px;
    text-align: center;
    line-height: 400px;
    img {
      width: 446px;
      height: 98px;
    }
  }
  .form {
    display: flex;
    justify-content: space-evenly;
    margin-top: 50px;
    align-items: center;
    font-size: 25px;
    .left {
      .left_top {
        margin-bottom: 10px;
        height: 60px;
      }
    }
    .right {
      .right_top {
        height: 60px;
        margin-bottom: 10px;
      }
    }
    input {
      border: none;
    }
  }
  .bom {
    width: 100%;
    display: flex;
    height: 50px;
    justify-content: space-around;
    margin-top: 20px;
    font-size: 15px;
    color: #bbb;
  }
  .button {
    width: 100%;
    height: 60px;
    text-align: center;
    button {
      color: #fff;
      width: 80%;
      height: 100%;
      border-radius: 10px;
      border: none;
      background: url()
        no-repeat;
      background-size: 100% 100%;
    }
  }
}
</style>
